package com.hairline.controller;

import com.hairline.bean.User;
import com.hairline.bean.vo.BaseRespVo;
import com.hairline.bean.vo.UserIndexVO;
import com.hairline.service.WxUserService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("wx/user")
public class WxUserController {

    @Autowired
    WxUserService wxUserService;

    @RequestMapping("index")
    public BaseRespVo userIndex() {
        Subject subject = SecurityUtils.getSubject();
        User user = (User) subject.getPrincipals().getPrimaryPrincipal();
        UserIndexVO userIndexVO = wxUserService.userIndex(user.getUsername());
        return BaseRespVo.ok(userIndexVO);
    }
}
